 
var pageContext = new PageContextDatatable(settings||{});
pageContext.setting.canShowPower = true;
pageContext.setting.canUpdatePower = true;

pageContext.formInit = function(layero){
	 
}
pageContext.renderAddPageOther = function(layero,data,option){
};
pageContext.renderUpdatePageOther = function(layero,data,option){
};


pageContext.renderAfterEventOther = function() {
}
pageContext.getOtherOperBtn = function(id,label){
	var html = [];	
	return html.join("");
}
pageContext.getOtherPingPuOperBtn = function(id,label){
	var html = [];
	return html.join("");
}
 
pageContext.renderAfterEventOther = function(){
	 
}
function nameFunc(data, type, record, meta){
	var id =  record[window.global.pcmap.get(meta.settings._objId).setting.prikey]; 
	var html = '';
	var name = data;
	var dir =  record["isParent"]; 
	var instanceId =  record["instanceId"]; 
	var relativeUrl = record["relativeUrl"];
	var baseUrl = record[ "url"];
	var href = window.global.getFinalUrl(window.global.ctx+ "/sys/file/download/"+id);
	if(dir=="true"||dir==true){
		html = "<i class='ace-icon fa dir-small bigger-120'></i>"+getDirName(name,instanceId,id)+"";
	}else{
		html += "<a href='"+href+"' title='下载【"+name+"】' target='_blank'>"+name+"</a>";
	}
	return html;
}
function getDirName(name,instanceId,id){
	var html = '';
	html+='<div class="file-name" style="width:60%">';
	html+='<span class="text">';
	var action = window.global.getFinalUrl(window.global.ctx+"/sys/file/index");
	action = window.global.addPara(action,"instanceId",instanceId,true)
	action = window.global.addPara(action,"pId",id,true)
	html+='<a href="javascript:void(0);" label="'+name+'" class="dir" url="'+action+'" title="打开目录'+name+'">'+name+'</a>';
	html+='</span>';
	html+='</div>';
	return html;
}

pageContext.importData = function(me){
	 var val = $(me).attr("val");
	 var label = $(me).attr("label");
	 var url = ($(me).attr("url"));
	var action = window.global.getFinalUrl(url);
	action = window.global.addPara(action,"parents",$("#searchForm input[name=_parents]").val(),true)
	action = window.global.addPara(action,"pId",$("#searchForm input[name=pId]").val(),true)
	load(action,"page-content",true,"新增"+pageContext.modelName,function(){
		
	});
   return false;
}
pageContext.toDetail = function(id,data){
	var action = window.global.getFinalUrl(pageContext.setting.toDetailUrl);
	action = window.global.addPara(action,"id",id,true)
	load(action,"page-content",true,pageContext.modelName+"详情",function(){
		
	});
}
pageContext.toUpdate = function(id,data){
	var action = window.global.getFinalUrl(pageContext.setting.toUpdateUrl);
	action = window.global.addPara(action,"id",id,true)
	load(action,"page-content",true,"修改"+pageContext.modelName,function(){
		
	});
}
$(function(){
	 pageContext.init();
	    var layero = $("#searchForm");
		layero.find('select[novalid!="true"]').each(function(){
			var novalid = $(this).attr("noconvert");
			if(novalid!="true"){
				var select2 = layero.find(this).select2({
		            language: "zh-CN"
		            ,matcher:select2Matcher}); 
			}
		  });
	 $('#'+pageContext.setting.tableId+' > tbody').on('click',"tr>td .dir", function(){
			var row = $(this);  
		    var url = row.attr("url");
			var label = row.attr("label");
			var action = window.global.getFinalUrl(url);
			load(action,"page-content",true,label,function(){
				
			});
	 });
})
